<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="button" id="btn" value="更换颜色" />
    <script>
        //1、绑定点击事件
        //2、随机生成一个RGB的颜色值
        //3、修改body标签的背景色(document.body.style.backgroundColor = 'rgb(1,1,1)')
        document.querySelector('#btn').onclick=function(){
            function num(min,max){
                return parseInt(Math.random()*(max+1-min))+min;
            }
            setInterval(function(){
                document.body.style.backgroundColor = `rgb(${num(0,255)},${num(0,255)},${num(0,255)})`
            })
        }
    </script>
</body>

</html>